<?php
/**
 * 摄影场景
 */
namespace app\index\controller;

use think\Controller;
use think\Request;

class Scene extends Common
{   
    public function _initialize()
    {
        parent::_initialize();
        $child=$this->getchild(31);
        $this->assign([
            'child'=>$child
        ]);
    }
    /**
     * 显示资源列表
     *
     * @return \think\Response
     */
    public function index($id)
    {
        if($id==null){
            $this->error("要访问的数据不存在！");
        }
        $res=db('article')->alias('a')
        ->join('pic p','p.aid=a.id')
        ->field('a.*,p.pic')
        ->where('a.cid',$id)
        ->paginate(6);

        $pos=$this->getPos($id);//当前位置
         $catename=db('category')->where('id',$id)->field('cate_name,desc,keyword')->find();
        $this->assign(array(
            'currid'=>$id,//当前栏目id
            'pos'   =>$pos,
            'res'   =>$res,
            'catename'=>$catename,
        ));
        return view();
    }

    /**
     * 摄影场景详情
     *
     * @return \think\Response
     */
    public function show($id)
    {
        $article=db('article')->where('id',$id)->find();
        $pos=$this->getPos($article['cid']);
        
        $this->assign([
            'article'=>$article,
            'currid' =>$article['cid'],
            'pos'    =>$pos,
        ]);
        return view();
    }

   
}
